package com.zx.ishopping.controller.User;

import com.github.pagehelper.Page;
import com.zx.ishopping.DTO.ProductPageDTO;

import com.zx.ishopping.entity.Products;
import com.zx.ishopping.results.PageResult;
import com.zx.ishopping.results.Result;
import com.zx.ishopping.services.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController("UserProductController")
@RequestMapping("/user/product")
public class ProductController {
    
    
    
    @Autowired
    private ProductService productService;

    /**
     * 用户分页查询
     * @param 
     * @return
     */
    
    @GetMapping("/getProductList")
    public Result<PageResult> getProductList(ProductPageDTO productPageDTO){
        PageResult  products = productService.getProductList(productPageDTO);
        return Result.success(products);
    }


    /**
     * 获取最畅销商品
     * @return
     */
    @GetMapping("/getBestSaleProductList")
    public Result<List<Products>> getBestSaleProductList(){
        log.info("获取最畅销商品");
        List<Products> products = productService.getBestSaleProductList();
        return Result.success(products);
    }
    
}
